import { defineStore } from 'pinia'

const useAppStore = defineStore({
    id: 'app',
    state: ()=>({
        sidebar: {
            opened: sessionStorage.getItem('sidebarStatus')=='1',
            withoutAnimation: false,
        },
        device: 'desktop'
    }),
    getters: {
        side: (state)=>state.sidebar,
        vice: (state)=>state.device
    },
    actions: {
        toggleSidebar(){
            if(this.sidebar.opened){
                sessionStorage.setItem('sidebarStatus', '0')
            }else{
                sessionStorage.setItem('sidebarStatus', '1')
            }
            this.sidebar.opened=!this.sidebar.opened
        },
        closeSidebar(withoutAnimation){
            sessionStorage.setItem('sidebarStatus', '0')
            this.sidebar.withoutAnimation = withoutAnimation
            this.sidebar.opened = false
        },
        toggleDevice(device){
           this.device = device
        }
    }
})

export default useAppStore